<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg">
  <head>
    <title>Standard Types</title>
    <link rel="stylesheet" type="text/css" href="docbook-epub.css"/>
    <link rel="stylesheet" type="text/css" href="kawa.css"/>
    <script src="kawa-ebook.js" type="text/javascript"/>
    <meta name="generator" content="DocBook XSL-NS Stylesheets V1.79.1"/>
    <link rel="prev" href="Types.xhtml" title="Types"/>
    <link rel="next" href="Parameterized-Types.xhtml" title="Parameterized Types"/>
  </head>
  <body>
    <header/>
    <section class="sect1" title="Standard Types" epub:type="subchapter" id="Standard-Types">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title" style="clear: both">Standard Types</h2>
          </div>
        </div>
      </div>
      <p>These types are predefined with the following names.
</p>
      <p>Instead of plain <code class="literal"><em class="replaceable"><code>typename</code></em></code> you can also use
the syntax <code class="literal">&lt;<em class="replaceable"><code>typename</code></em>&gt;</code> with angle brackets,
but that syntax is no longer recommended, because it doesn’t
“fit” as well with some ways type names are used.
</p>
      <p>To find which Java classes these types map into, look in
<code class="literal">kawa/standard/Scheme.java</code>.
</p>
      <p>Note that the value of these variables are instances
of <code class="literal">gnu.bytecode.Type</code>,
not (as you might at first expect) <code class="literal">java.lang.Class</code>.
</p>
      <p>The numeric types (<code class="literal">number</code>, <code class="literal">quantity</code>,
<code class="literal">complex</code>, <code class="literal">real</code>, <code class="literal">rational</code>, <code class="literal">integer</code>,
<code class="literal">long</code>, <code class="literal">int</code>, <code class="literal">short</code>, <code class="literal">byte</code>
<code class="literal">ulong</code>, <code class="literal">uint</code>, <code class="literal">ushort</code>, <code class="literal">ubyte</code>,
<code class="literal">double</code>, <code class="literal">float</code>)
are discussed in <a class="link" href="Numerical-types.xhtml" title="Numerical types">Numerical types</a>.
</p>
      <p>The types <code class="literal">character</code> and <code class="literal">char</code>
are discussed in <a class="link" href="Characters.xhtml" title="Characters">Characters</a>.
</p>
      <p class="synopsis" kind="Variable"><span class="kind">Variable</span><span class="ignore">: </span><a id="idm139667871985744" class="indexterm"/> <code class="varname">Object</code></p>
      <div class="blockquote">
        <blockquote class="blockquote">
          <p>An arbitrary Scheme value - and hence an arbitrary Java object.
</p>
        </blockquote>
      </div>
      <p class="synopsis" kind="Variable"><span class="kind">Variable</span><span class="ignore">: </span><a id="idm139667871982736" class="indexterm"/> <code class="varname">symbol</code></p>
      <div class="blockquote">
        <blockquote class="blockquote">
          <p>The type of Scheme symbols.
(Implemented using the Java class <code class="literal">gnu.mapping.Symbol</code>.)
(<span class="emphasis"><em>Compatibility:</em></span> Previous versions of Kawa implemented
a simple Scheme symbol using an interned <code class="literal">java.lang.String</code>.)
</p>
        </blockquote>
      </div>
      <p class="synopsis" kind="Variable"><span class="kind">Variable</span><span class="ignore">: </span><a id="idm139667871978352" class="indexterm"/> <code class="varname">keyword</code></p>
      <div class="blockquote">
        <blockquote class="blockquote">
          <p>The type of keyword values.  See <a class="link" href="Keywords.xhtml" title="Keywords">Keywords</a>.
</p>
        </blockquote>
      </div>
      <p class="synopsis" kind="Variable"><span class="kind">Variable</span><span class="ignore">: </span><a id="idm139667871974688" class="indexterm"/> <code class="varname">list</code></p>
      <div class="blockquote">
        <blockquote class="blockquote">
          <p>The type of Scheme lists (pure and impure, including the empty list).
</p>
        </blockquote>
      </div>
      <p class="synopsis" kind="Variable"><span class="kind">Variable</span><span class="ignore">: </span><a id="idm139667871971680" class="indexterm"/> <code class="varname">pair</code></p>
      <div class="blockquote">
        <blockquote class="blockquote">
          <p>The type of Scheme pairs.  This is a sub-type of <code class="literal">list</code>.
</p>
        </blockquote>
      </div>
      <p class="synopsis" kind="Variable"><span class="kind">Variable</span><span class="ignore">: </span><a id="idm139667871968272" class="indexterm"/> <code class="varname">string</code></p>
      <div class="blockquote">
        <blockquote class="blockquote">
          <p>The type of Scheme strings.
(Implemented using <code class="literal">java.lang.String</code> for immutable strings,
and <code class="literal">gnu.lists.FString</code> for mutable strings.
Both of these implement the interface <code class="literal">java.lang.CharSequence</code>.
In the future, we may change the representation for strings
containing “surrogate characters”, for efficient indexing.)
(<span class="emphasis"><em>Compatibility:</em></span> Previous versions of Kawa
always used <code class="literal">gnu.lists.FString</code>.)
</p>
        </blockquote>
      </div>
      <p class="synopsis" kind="Variable"><span class="kind">Variable</span><span class="ignore">: </span><a id="idm139667871962848" class="indexterm"/> <code class="varname">character</code></p>
      <div class="blockquote">
        <blockquote class="blockquote">
          <p>The type of Scheme character values.  This is a sub-type of
<code class="literal">Object</code>, in contrast to type <code class="literal">char</code>, which is the
primitive Java <code class="literal">char</code> type.
</p>
        </blockquote>
      </div>
      <p class="synopsis" kind="Variable"><span class="kind">Variable</span><span class="ignore">: </span><a id="idm139667871958480" class="indexterm"/> <code class="varname">vector</code></p>
      <div class="blockquote">
        <blockquote class="blockquote">
          <p>The type of Scheme vectors.
</p>
        </blockquote>
      </div>
      <p class="synopsis" kind="Variable"><span class="kind">Variable</span><span class="ignore">: </span><a id="idm139667871955504" class="indexterm"/> <code class="varname">procedure</code></p>
      <div class="blockquote">
        <blockquote class="blockquote">
          <p>The type of Scheme procedures.
</p>
        </blockquote>
      </div>
      <p class="synopsis" kind="Variable"><span class="kind">Variable</span><span class="ignore">: </span><a id="idm139667871952528" class="indexterm"/> <code class="varname">input-port</code></p>
      <div class="blockquote">
        <blockquote class="blockquote">
          <p>The type of Scheme input ports.
</p>
        </blockquote>
      </div>
      <p class="synopsis" kind="Variable"><span class="kind">Variable</span><span class="ignore">: </span><a id="idm139667871949552" class="indexterm"/> <code class="varname">output-port</code></p>
      <div class="blockquote">
        <blockquote class="blockquote">
          <p>The type of Scheme output ports.
</p>
        </blockquote>
      </div>
      <p class="synopsis" kind="Variable"><span class="kind">Variable</span><span class="ignore">: </span><a id="idm139667871946576" class="indexterm"/> <code class="varname">String</code></p>
      <div class="blockquote">
        <blockquote class="blockquote">
          <p>This type name is a special case.  It specifies the class
<code class="literal">java.lang.String</code>.
However, coercing a value to <code class="literal">String</code> is done by
invoking the <code class="literal">toString</code> method on the value to be coerced.
Thus it "works" for all objects.
It also works for <code class="literal">#!null</code>.
</p>
          <p>When Scheme code invokes a Java method, any parameter
whose type is <code class="literal">java.lang.String</code> is converted
as if it was declared as a <code class="literal">String</code>.
</p>
        </blockquote>
      </div>
      <p class="synopsis" kind="Variable"><span class="kind">Variable</span><span class="ignore">: </span><a id="idm139667871940336" class="indexterm"/> <code class="varname">parameter</code></p>
      <div class="blockquote">
        <blockquote class="blockquote">
          <p>A parameter object, as created by <code class="literal">make-parameter</code>.
This type can take a type parameter (sic):
</p>
          <pre class="screen">(define-constant client ::parameter[Client] (make-parameter #!null))
</pre>
          <p>This lets Kawa know that reading the parameter (as in <code class="literal">(client)</code>)
returns a value of the specified type (in this case <code class="literal">Client</code>).
</p>
        </blockquote>
      </div>
      <p>More will be added later.
</p>
      <p>A type specifier can also be one of the primitive Java types.
The numeric types <code class="literal">long</code>, <code class="literal">int</code>, <code class="literal">short</code>,
<code class="literal">byte</code>, <code class="literal">float</code>, and <code class="literal">double</code> are converted from the
corresponding Scheme number classes.  Similarly, <code class="literal">char</code>
can be converted to and from Scheme characters.  The type
<code class="literal">boolean</code> matches any object, and the result is <code class="literal">false</code>
if and only if the actual argument is <code class="literal">#f</code>.
(The value <code class="literal">#f</code> is identical to <code class="literal">Boolean.FALSE</code>,
and <code class="literal">#t</code> is identical to <code class="literal">Boolean.TRUE</code>.)
The return type <code class="literal">void</code> indicates that no value is returned.
</p>
      <p>A type specifier can also be a fully-qualified Java class name
(for example <code class="literal">java.lang.StringBuffer</code>).  In that case,
the actual argument is cast at run time to the named class.
Also, <code class="literal">java.lang.StringBuffer[]</code> represents
an array of references to <code class="literal">java.lang.StringBuffer</code> objects.
</p>
      <span id="dynamic-type"/>
      <p class="synopsis" kind="Variable"><span class="kind">Variable</span><span class="ignore">: </span><a id="idm139667871925472" class="indexterm"/> <code class="varname">dynamic</code></p>
      <div class="blockquote">
        <blockquote class="blockquote">
          <p>Used to specify that the type is unknown, and is likely to change
at run-time.
Warnings about unknown member names are supressed
(a run-time name lookup is formed).
An expression of type <code class="literal">dynamic</code> is (statically) compatible with
any type.
</p>
        </blockquote>
      </div>
    </section>
    <footer>
      <div class="navfooter">
        <p>
          Up: <a accesskey="u" href="Types.xhtml">Types</a></p>
        <p>
        Next: <a accesskey="n" href="Parameterized-Types.xhtml">Parameterized Types</a></p>
      </div>
    </footer>
  </body>
</html>
